// TypeScript file
module tool {
    export class SendData {
        public static sendJoinData(): any {//根据地址判断是来创建房间还是来进入房间的
            var obj = {}
            var dataURL = SoundMenager.urlSearch()//获取地址后面接的参数
            if (dataURL && dataURL["room_id"]) {//房间号存在，发送要加入房间的信息
                obj["operation"] = view.GameViewPlay.PrepareJoinRoom
                var dataURL = SoundMenager.urlSearch()//获取地址后面接的参数
                obj['data'] = {};
                if (dataURL["member_id"]) {//加入房间
                    obj["account_id"] = dataURL["member_id"];
                    window.localStorage.setItem("account_id", dataURL["member_id"]);
                } else {
                    obj["account_id"] = window.localStorage.getItem("account_id");
                }
                if (dataURL["room_id"]) {//加入房间
                    obj["data"]["room_number"] = dataURL["room_id"];
                    window.localStorage.setItem("room_number", dataURL["room_id"]);
                }

            } else {//房间号不存在，发送要创建的房间信息
                if(!window.localStorage.getItem("room_number")){
                    obj["operation"] = view.GameViewPlay.CreateRoom
                    obj["account_id"] = window.localStorage.getItem("account_id");
                    obj['data'] = {}
                    obj['data']['ticket_type'] = window.localStorage.getItem("ticket_type")//房卡模式
                    obj['data']['score_type'] = window.localStorage.getItem("score_type") //低分
                    obj['data']['rule_type'] = window.localStorage.getItem("rule_type") //规则
                    obj['data']['banker_mode'] = window.localStorage.getItem("banker_mode"); //庄家模式
                    obj['data']['is_cardfive'] = ""
                    obj['data']['is_cardbomb'] = ""
                    obj['data']['is_cardtiny'] = ""
                    obj['data']['banker_score_type'] = ""//庄家底分
                }else{
                   obj=SendData.sendPrepareJoinRoomData();
                }
            }
            return obj;
        }
        public static sendPrepareJoinRoomData(): any {//发送准备加入房间的数据
            var obj = {}
            obj["operation"] = view.GameViewPlay.PrepareJoinRoom
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_number"] = window.localStorage.getItem("room_number");
            return obj;
        }
        public static sendJoinRoomData(): any {//发送进入房间的数据
            var obj = {}
            obj["operation"] = view.GameViewPlay.JoinRoom
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_number"] = window.localStorage.getItem("room_number");
            return obj;
        }
        public static sendPullRoomInfoData(): any {//拉取所有玩家信息
            var obj = {}
            obj["operation"] = view.GameViewPlay.PullRoomInfo
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_number"] = window.localStorage.getItem("room_number");
            return obj;
        }
        public static sendReadyStartData(): any {//发送游戏开始
            var obj = {}
            obj["operation"] = view.GameViewPlay.ReadyStart
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_id"] = window.localStorage.getItem("room_id");
            return obj;
        }
        public static sendGrabBankerData(is_grab, multiples): any {//抢庄
            var obj = {}
            obj["operation"] = view.GameViewPlay.GrabBanker
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_id"] = window.localStorage.getItem("room_id")
            obj['data']['is_grab'] = is_grab
            obj['data']['multiples'] = multiples
            return obj;
        }
        public static sendPlayerMultiplesData(multiples): any {//手动下注
            var obj = {}
            obj["operation"] = view.GameViewPlay.PlayerMultiples
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_id"] = window.localStorage.getItem("room_id")
            obj['data']['multiples'] = multiples
            return obj;
        }
        public static sendShowCardData(): any {//玩家手动摊牌
            var obj = {}
            obj["operation"] = view.GameViewPlay.ShowCard
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_id"] = window.localStorage.getItem("room_id")
            return obj;
        }
        public static sendControllerData(): any {//控制器发送
            var obj = {}
            obj["operation"] = view.GameViewPlay.Controller
            return obj;
        }
        public static sendBroadcastVoiceData(voice_num): any {//广播
            var obj = {}
            obj["operation"] = view.GameViewPlay.BroadcastVoice
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_id"] = window.localStorage.getItem("room_id")
            obj["data"]["voice_num"] = voice_num
            return obj;
        }
        public static sendKickCardData(kickcard): any {//踢牌
            var obj = {}
            obj["operation"] = "PlayerKickCard"
            obj["account_id"] = window.localStorage.getItem("account_id")
            obj['data'] = {}
            obj["data"]["room_id"] = window.localStorage.getItem("room_id")
            obj["data"]["kick_card"] = kickcard
            return obj;
        }
        public static strReplace(str: string): string {
            return str;
            //    if(str){
            //        return str.replace("http://wx.qlogo.cn","http://game.wxsd.com")
            //     }
            //    return "";

        }
    }
}